package mapred;

import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.compress.CompressionCodec;
import org.apache.hadoop.mapred.OutputFormat;

@SuppressWarnings("unchecked")
public class OutputConfig {

	private Class<? extends OutputFormat> outputFormat;

	private Class<? extends Writable> outputKeyClass;

	private Class<? extends Writable> outputValueClass;

	private String outputPath;

	private boolean compressOutput;

	private Class<? extends CompressionCodec> outputCompressorClass;

	private OutputConfig(Class<? extends OutputFormat> outputFormat,
			Class<? extends Writable> outputKeyClass,
			Class<? extends Writable> outputValueClass, String outputPath,
			Class<? extends CompressionCodec> outputCompressorClass) {
		this.outputFormat = outputFormat;
		this.outputKeyClass = outputKeyClass;
		this.outputValueClass = outputValueClass;
		this.outputPath = outputPath;
		this.compressOutput = (outputCompressorClass != null);
		this.outputCompressorClass = outputCompressorClass;
	}

	public static OutputConfig newInstance(
			Class<? extends OutputFormat> outputFormat,
			Class<? extends Writable> outputKeyClass,
			Class<? extends Writable> outputValueClass, String outputPath,
			Class<? extends CompressionCodec> outputCompressorClass) {
		return new OutputConfig(outputFormat, outputKeyClass, outputValueClass,
				outputPath, outputCompressorClass);
	}

	public Class<? extends OutputFormat> getOutputFormat() {
		return outputFormat;
	}

	public Class<? extends Writable> getOutputKeyClass() {
		return outputKeyClass;
	}

	public Class<? extends Writable> getOutputValueClass() {
		return outputValueClass;
	}

	public String getOutputPath() {
		return outputPath;
	}

	public boolean isCompressOutput() {
		return compressOutput;
	}

	public Class<? extends CompressionCodec> getOutputCompressorClass() {
		return outputCompressorClass;
	}

}
